﻿using System.Web.Mvc;
using TNPTN.Models;

namespace TNPTN.Controllers
{
    /// <summary>
    /// Base controller
    /// Author: jabraok
    /// </summary>
    public class BaseController : Controller
    {
        /// <summary>
        /// Change lanuage
        /// </summary>
        /// <param name="returnURL">return URL</param>
        /// <param name="langID">language ID</param>
        /// <returns>ActionResult</returns>
        public ActionResult ChangeLang(string returnURL, Enums.LanguageID langID)
        {
            TNPTN.Session.Info.LangID = langID;
            return Redirect(returnURL);
        }

        /// <summary>
        /// Download file
        /// </summary>
        /// <param name="fileName">file name</param>
        protected void DownloadFile(string fileName)
        {
            Response.Clear();
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ";");
            Response.TransmitFile(this.Server.MapPath("~/Files/" + fileName));
            // Add redirect here if you like
            Response.End();
        }
    }
}
